package com.blacktry.controller;

import com.blacktry.entity.enums.OprLogConst;
import com.blacktry.entity.model.ApiResult;
import com.blacktry.service.EasyPoiService;
import com.blacktry.utils.ApiResultHandler;
import com.blacktry.utils.log.OperLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/EasyPoi")
@Api(value="EasyPoi类模块", tags = "EasyPoi")
public class EasyPoiController {

    @Autowired
    private EasyPoiService easyPoiService;

    @OperLog(operModul = "EasyPoi类管理-根据数据的ids导出数据",operType = OprLogConst.SELECT,operDesc = "根据数据的ids导出数据")
    @ApiOperation("根据数据的ids导出数据")
    @GetMapping("/writeListByIds")
    public void writeListByIds(@RequestParam("ids") String[] ids, HttpServletResponse response) throws IOException {
        easyPoiService.writeListByIds(ids,response);
    }

    @OperLog(operModul = "EasyPoi类管理-根据Excel导入数据",operType = OprLogConst.ADD,operDesc = "根据Excel导入数据")
    @ApiOperation("根据Excel导入数据")
    @PostMapping("/readListByExcel")
    public ApiResult<String> readListByExcel(MultipartFile file){
        return ApiResultHandler.buildApiResult(200,"成功",easyPoiService.readListByExcel(file));
    }

}
